classdef ziPath < handle
    %ZIPITH Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        device
        channel_name
        channel_index
        sample_name
        node_name
    end
    
    methods
        function obj = ziPath(dev, channel, chIndex, sample, node)
            %ZIPITH Construct an instance of this class
            %   Detailed explanation goes here
            chIndexStr =  toStr(chIndex);
            obj.device = dev;
            obj.channel_name = channel;
            obj.channel_index = chIndexStr;
            obj.sample_name = sample;
            obj.node_name = node;
        end
        
        function s = path_string(obj)
            s = ['/' obj.device '/' obj.channel_name '/' obj.channel_index '/' obj.sample_name];
        end
        
        function s = path_channel_string(obj)
            s = ['/' obj.device '/' obj.channel_name '/' obj.channel_index ];
        end
        
        function s = channel_node_str(obj)
            s.channel = obj.channel_index;
            s.node = obj.node_name;
            s.str = [obj.channel_index '_{' obj.node_name '}'];
        end
        
        function s = channel_sample_str(obj)
            s.channel = obj.channel_index;
            s.node = obj.sample_name;
            s.str = [obj.channel_index '_{' obj.sample_name '}'];
        end
        
    end
end

function s = toStr(chIndex)
    if isnumeric(chIndex)
        s = sprintf('%d', chIndex-1);
    else
        s = chIndex;
    end

end
